<?php
namespace Common\Model;
use Think\Model;
use Think\Page;
use Common\Model\VRAdminModel;
class UserMerssageModel extends VRUserModel
{
	//消息分页
	function getpage($pagesize=5){
		$count = $this->where(array('send_status'=>'1'))->count();
		$p=new \Think\Page($count,$pagesize);
		$p->lastSuffix=false;
		$p->setConfig('prev','上一页');
		$p->setConfig('next','下一页');
		$p->setConfig('last','末页');
		$p->setConfig('first','首页');
		$p->parameter=I('get.');

		$this->limit($p->firstRow,$p->listRows);

		return $p;
	}

	//通知分页
	function getpage1($pagesize=5){
		$count = $this->where(array('send_status'=>'0'))->count();
		$p=new \Think\Page($count,$pagesize);
		$p->lastSuffix=false;
		$p->setConfig('prev','上一页');
		$p->setConfig('next','下一页');
		$p->setConfig('last','末页');
		$p->setConfig('first','首页');
		$p->parameter=I('get.');

		$this->limit($p->firstRow,$p->listRows);

		return $p;
	}

	//查询消息
	function serach($title,$send_date,$type,$status){
		$where['title'] = array('like',"%$title%");
		$where['send_date'] = array('like',"%$send_date%");
		$where['type'] = array('like',"%$type%");
		$where['status'] = array('like',"%$status%");      //状态 0:发送失败,1:发送完毕 
		$where['send_status'] = '1'; 
		return $this->where($where)->select();
	}

	//查询通知
	function serach1($title,$send_date,$status){
		$where['title'] = array('like',"%$title%");
		$where['send_date'] = array('like',"%$send_date%");
		$where['status'] = array('like',"%$status%");      //状态 0:发送失败,1:发送完毕 
		$where['send_status'] = '0';
		return $this->where($where)->select();
	}
}